package com.mszlu.blog.controller;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.annotation.JsonAlias;
import com.mszlu.blog.common.Result;
import com.mszlu.blog.entity.SysUser;
import com.mszlu.blog.service.LoginService;
import com.mszlu.blog.service.SysUserServive;
import com.mszlu.blog.utils.JWTUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.DigestUtils;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/users")
public class SysUserController {

    @Autowired
    private LoginService loginService;

    @Autowired
    private RedisTemplate<String,String> redisTemplate;

    @GetMapping("/currentUser")
    public Result currentUser(@RequestHeader("Authorization") String token){

        SysUser parse = loginService.checkLogin(token);
        if (parse == null){
            return Result.tokenError("token不合法");
        }

        return Result.success(parse);
    }




}
